$('label').each(function(){
	var checkbox = $(this).children(":first");
	var input = $(this).parent().next();
	
	if(checkbox.attr("checked") != true){
		input.hide();
	}

	checkbox.change(function(){
		var input = $(this).parent().parent().next();
		if($(this).attr("checked") != true){
			input.hide();
		}else{
			input.show();
		}
	});
});

$('#check_all').click(function(){
	$('form :checkbox').attr("checked", $(this).attr("checked"));
	$('form :checkbox').change();
});

$('#reverse_all').click(function(){
	$('form :checkbox').click();
	$('form :checkbox').change();
});

function setProjectCreditedTime(season){
	var d = new Date();
	var year = d.getFullYear();
	var season = parseInt(season, 10);
	switch(season){
		case 1:
			var from = '1-1';
			var to = '3-30';
		break;
		case 2:
			var from = '4-1';
			var to = '6-30';
		break;
		case 3:
			var from = '7-1';
			var to = '9-30';
		break;
		case 4:
			var from = '10-1';
			var to = '12-31';
		break;
	}
	$('#project_creditedtime_from').datebox('setValue', year + '-' + from);
	$('#project_creditedtime_to').datebox('setValue', year + '-' + to);
}